//
//  RMMGoodsConfirmViewController.m
//  Romomo
//
//  Created by puman on 16/10/10.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMGoodsConfirmViewController.h"
#import "RMMShopingConfirmTableViewCell.h"
#import "RMMShopingZeKouTableViewCell.h"
#import "RMMYanZhiTableViewCell.h"
#import "RMMShopingTableViewCell.h"
#import "RMMGoogsConfirmHeadView.h"
#import "RMMConfirmOrderView.h"
#import "RMMYouHuiQuanViewController.h"
#import "RMMUpOrderViewController.h"
#import "RMMShopingModel.h"
#import "RMMGoodsDetialsViewController.h"
#import "RMMOrderModel.h"
#import "RMMChosseDateViewController.h"

@interface RMMGoodsConfirmViewController ()<UITableViewDelegate, UITableViewDataSource>

@end

@implementation RMMGoodsConfirmViewController
{
    UITableView *_tableView;
    UITableView *_tuiJianTableView;
    NSMutableArray *_tuiJianArray;
    CGFloat _totalPrcie;
    RMMGoogsConfirmHeadView *_headView;
    NSMutableArray *_arrayT;
    RMMConfirmOrderView *_confirmOrderViwe;
    UIButton *_moreBut;
    NSDictionary *_youHuiQuanDic;
    NSString *_yanZhiText;
    NSString *_youHuiMoney;
    NSString *_youHuiQuanText;
    NSString *_is_face;
    NSString *_voucher_id;
    BOOL _isUsedYouHuiCard;
    NSMutableDictionary *_youHuiDic;
}
- (void)dealloc {
    [_youHuiDic removeAllObjects];
    NS_REM(@"USEYOUHUIQUAN", nil);
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    self.navigationItem.title = @"确认商品信息";
    
    [self addViews];
    if (_order_id.length) {
    } else {
        [self getRequestData];
    }
    // Do any additional setup after loading the view.
}
- (void)getData{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    NSString *url = GetDisCountAmtUrl;
    dic[@"cust_id"] = [RMMFileManager shareHandle].userDic[@"CUST_ID"];
    dic[@"originalprice"] = [NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
    dic[@"is_face"] = _is_face;
    dic[@"is_home"] = [RMMFileManager shareHandle].fuWuType;
    if (_order_id.length) {
        dic[@"order_id"] = _order_id;
    }
    if (_voucher_id.length) {
        dic[@"voucher_id"] = _voucher_id;
    }
    [OSRequestManager requestWithUrlString:url parDic:dic method:GET finish:^(NSDictionary *dataDic) {
        NSString *status = [NSString stringWithFormat:@"%@",dataDic[@"status"]];
        if ([status isEqualToString:@"1"]) {
            if ([_is_face isEqualToString:@"1"]) {
                _yanZhiText = [NSString stringWithFormat:@"%.2f",[dataDic[@"data"][@"FACE_ATM"] floatValue]];
            }
        } else {
            [RMMFileManager MBProgressWith:dataDic[@"message"] onView:self.view];
        }
        [_tableView reloadData];
    } error:^(NSError *errors) {
        
    } view:self.view];
}
- (void)getRequestData{
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    NSMutableArray *array = [NSMutableArray array];
    for (RMMShopingModel *model in _goodsArray) {
        [array addObject:model.SERVICE_ID];
    }
    NSString *string = [array componentsJoinedByString:@","];
    parDic[@"org_no"] = Org_no;
    parDic[@"server_id"] = string;
    NSString *url = GetTuiJianUrl;
    if (array.count) {
        [OSRequestManager requestWithUrlString:url parDic:parDic method:GET finish:^(NSDictionary *dataDic) {
            NSString *status = [NSString stringWithFormat:@"%@",dataDic[@"status"]];
            if ([status isEqualToString:@"1"]) {
                NSArray *array = dataDic[@"data"];
                for (NSDictionary *dic in array) {
                    RMMShopingModel *model = [[RMMShopingModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    model.COUNT = @1;
                    model.MY_CARD_ID = @"0";
                    [_arrayT addObject:model];
                }
                if (_arrayT.count > 3) {
                    _tableView.tableFooterView = _moreBut;
                } else {
                    _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, 0)];
                }
            } else {
                [RMMFileManager MBProgressWith:dataDic[@"message"] onView:self.view];
            }
            [_tableView reloadSections:[[NSIndexSet alloc] initWithIndex:2] withRowAnimation:(UITableViewRowAnimationFade)];
        } error:^(NSError *errors) {
            
        } view:self.view];
    }
}
- (void)addViews{
    _youHuiDic = [NSMutableDictionary dictionary];
    _tuiJianArray = [NSMutableArray array];
    _arrayT = [NSMutableArray array];
    _yanZhiText = @"0";
    _youHuiMoney = @"0";
    _voucher_id = @"";
    _is_face = @"0";
    _totalPrcie = 0.00;;
    _isUsedYouHuiCard = NO;
    _isFromToTaoCan = NO;
    _youHuiQuanText = @"选择您想使用的优惠券";
    _totalPrcie = [self getToatalPriceWithArray:_goodsArray];
    if (_totalPrcie > 0) {
        _isFromToTaoCan = NO;
    } else {
        _isFromToTaoCan = YES;
    }
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, kScreenHeight - 64 - 49)];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.separatorStyle = NO;
    [_tableView registerClass:[RMMShopingConfirmTableViewCell class] forCellReuseIdentifier:@"Cell"];
    [_tableView registerClass:[RMMShopingZeKouTableViewCell class] forCellReuseIdentifier:@"ZeCell"];
    [_tableView registerClass:[RMMYanZhiTableViewCell class] forCellReuseIdentifier:@"YanZhiCell"];
    [_tableView registerClass:[RMMShopingTableViewCell class] forCellReuseIdentifier:@"TuiJianCell"];
    [self.view addSubview:_tableView];
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight - 49 - 64, kScreenWideth, 49)];
    bottomView.backgroundColor = kWhiteColor;
    [self.view addSubview:bottomView];
    
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, bottomView.width, 0.5)];
    lineLabel.backgroundColor = RGBA(221, 221, 221, 1);
    [bottomView addSubview:lineLabel];
    
    UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    button.frame = CGRectMake(kScreenWideth / 2 - kHalf * 2, 6.5, 4 * kHalf, 36);
    button.backgroundColor = kBasicColor;
    [button setTitleColor:kWhiteColor forState:(UIControlStateNormal)];
    button.titleLabel.font = kBFont(14);
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius = 18;
    [button setTitle:@"确认订单并预约" forState:(UIControlStateNormal)];
    BUTTON_S(button, confirmOderBut);
    [bottomView addSubview:button];
    
    _moreBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _moreBut.frame = CGRectMake(0, 0, kScreenWideth, 44);
    _moreBut.backgroundColor = kWhiteColor;
    [_moreBut setTitle:@"显示更多" forState:(UIControlStateNormal)];
    [_moreBut setTitleColor:kBasicColor forState:(UIControlStateNormal)];
    _moreBut.titleLabel.font = kFont(16);
    BUTTON_S(_moreBut, moreButClick);
    NS_ADD(useYouHuiQuan:, @"USEYOUHUIQUAN", nil);
}
- (void)useYouHuiQuan:(NSNotification *)nofitication{
    NSDictionary *dic = [nofitication userInfo];
    if (dic == nil) {
        _youHuiQuanText = @"选择您想使用的优惠券";
        [_youHuiDic removeObjectForKey:@"优惠券信息"];
        _isUsedYouHuiCard = NO;
    } else {
        _youHuiQuanDic = dic;
        _youHuiQuanText = [NSString stringWithFormat:@"%@",dic[@"VOUCHER_NAME"]];
        _voucher_id = [NSString stringWithFormat:@"%@",dic[@"VOUCHER_ID"]];
        [_youHuiDic setValue:dic forKey:@"优惠券信息"];
        _isUsedYouHuiCard = YES;
        [self getData];
    }
    [_tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return _goodsArray.count;
    } else if (section == 1) {
        return 2;
    } else {
        return _arrayT.count;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 2 * kHalf - 1;
    } else if (indexPath.section == 2) {
        return 100;
    } else {
        if (_isFromToTaoCan) {
            return 0;
        } else {
            return 49;
        }
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        _headView = [[RMMGoogsConfirmHeadView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, kHalf + 4)];
        NSInteger count = 0;
        for (RMMShopingModel *models in _arrayT) {
            if ([models.isSelect isEqualToString:@"1"]) {
                count += 1;
            }
        }
        _headView.selctLabel.text = [NSString stringWithFormat:@"%ld",count];
        if (count == 0) {
            _headView.selctLabel.backgroundColor = kWhiteColor;
        } else {
            _headView.selctLabel.backgroundColor = [UIColor redColor];
        }
        return _headView;
    } else {
        return nil;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return kHalf + 4;
    } else {
        return 0;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        RMMShopingConfirmTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.model = _goodsArray[indexPath.row];
        return cell;
    } else if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            RMMShopingZeKouTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZeCell"];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.zeKouLabel.text = _youHuiQuanText;
            return cell;
        } else {
            RMMYanZhiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YanZhiCell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.titleLabel.text = [NSString stringWithFormat:@"可使用颜值分抵扣%@元",_yanZhiText];
            [cell.mySwitch addTarget:self action:@selector(swithClick:) forControlEvents:(UIControlEventValueChanged)];
            return cell;
        }
    } else {
        RMMShopingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TuiJianCell"];
        RMMShopingModel *model = _arrayT[indexPath.row];
        cell.model = model;
        cell.cellSelectBut.tag = indexPath.row + 100;
        cell.subBut.tag = indexPath.row + 200;
        cell.addBut.tag = indexPath.row + 300;
        BUTTON_S(cell.cellSelectBut, cellSelectButClick:);
        BUTTON_S(cell.subBut, subButClick:);
        BUTTON_S(cell.addBut, addButClick:);
        cell.countLabel.text = [NSString stringWithFormat:@"%@",model.COUNT];
        if ([model.isSelect isEqualToString:@"1"]) {
            [cell.subBut setImage:[UIImage imageNamed:@"un-subtract@3x"] forState:(UIControlStateNormal)];
            cell.subBut.userInteractionEnabled = NO;
        } else {
            [cell.subBut setImage:[UIImage imageNamed:@"subtract@3x"] forState:(UIControlStateNormal)];
            cell.subBut.userInteractionEnabled = YES;
        }

        return cell;
    }
}
- (void)swithClick:(UISwitch *)swith{
    if (swith.on) {
        _is_face = @"1";
        [self getData];
    } else {
        _is_face = @"0";
        _yanZhiText = @"0";
        [_tableView reloadData];
    }

}
- (void)cellSelectButClick:(UIButton *)button{
    RMMShopingModel *model = _arrayT[button.tag - 100];
    if ([model.isSelect isEqualToString:@"1"]) {
        model.isSelect = @"0";
        [button setImage:[UIImage imageNamed:@"可选@3x"] forState:(UIControlStateNormal)];
    } else {
        model.isSelect = @"1";
        [button setImage:[UIImage imageNamed:@"选中@3x"] forState:(UIControlStateNormal)];
    }
    _confirmOrderViwe.totalPrice.text = [NSString stringWithFormat:@"¥ %.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
    CGFloat totalPrice = [self getToatalPriceWithArray:_arrayT] + _totalPrcie;
    if (totalPrice > 0) {
        _isFromToTaoCan = NO;
    } else {
        _isFromToTaoCan = YES;
    }
    [_tableView reloadData];
}
- (void)subButClick:(UIButton *)button{
    RMMShopingModel *model = _arrayT[button.tag - 200];
    NSInteger cout = [model.COUNT integerValue];
    if (cout == 1) {
        [button setImage:[UIImage imageNamed:@"un-subtract@3x"] forState:(UIControlStateNormal)];
        button.userInteractionEnabled = NO;
    } else {
        cout -= 1;
        model.COUNT = [NSNumber numberWithInteger:cout];
    }
    [_tableView reloadData];
    _confirmOrderViwe.totalPrice.text = [NSString stringWithFormat:@"¥ %.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
}
- (void)addButClick:(UIButton *)button{
    RMMShopingModel *model = _arrayT[button.tag - 300];
    NSInteger cout = [model.COUNT integerValue];
    if (cout == 99) {
        [RMMFileManager MBProgressWith:@"单一服务数量不能超过99!" onView:self.view];
    } else {
        cout += 1;
        model.COUNT = [NSNumber numberWithInteger:cout];
        if (cout >= 2) {
            UIButton *but = [self.view viewWithTag:button.tag - 100];
            [but setImage:[UIImage imageNamed:@"subtract@3x"] forState:(UIControlStateNormal)];
            but.userInteractionEnabled = YES;
        }
    }
    [_tableView reloadData];
    _confirmOrderViwe.totalPrice.text = [NSString stringWithFormat:@"¥ %.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            RMMYouHuiQuanViewController *VC = [[RMMYouHuiQuanViewController alloc] init];
            [self.navigationController pushViewController:VC animated:YES];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
    } else if (indexPath.section == 2) {
        RMMGoodsDetialsViewController *VC = [[RMMGoodsDetialsViewController alloc] init];
        RMMShopingModel *model = _arrayT[indexPath.row];
        VC.service_id = model.SERVICE_ID;
        [self.navigationController pushViewController:VC animated:YES];
    }
}
// 确定订单并预约
- (void)confirmOderBut{
    NSInteger totalTime = 0;
    if (_order_id.length) {
        for (RMMShopingModel *model in _goodsArray) {
            NSInteger time = [model.TIME_LEN integerValue] * [model.COUNT integerValue];
            totalTime += time;
        }
        [RMMFileManager shareHandle].totalTimeLength = [NSString stringWithFormat:@"%ld",totalTime];
        RMMUpOrderViewController *VC = [[RMMUpOrderViewController alloc] init];
        [_youHuiDic setValue:_yanZhiText forKey:@"颜值"];
        [_youHuiDic setValue:_is_face forKey:@"是否使用颜值"];
        [_youHuiDic setValue:[NSString stringWithFormat:@"%d",_isUsedYouHuiCard] forKey:@"是否使用优惠券"];
        [_youHuiDic setObject:[NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie] forKey:@"总价钱"];
        [RMMFileManager shareHandle].totalPrcie = [NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
        [self processData];
        NSMutableArray *gArray = [NSMutableArray arrayWithArray:_goodsArray];
        VC.dataArray = gArray;
        VC.youHuiDic = _youHuiDic;
        VC.isHome = _isHome;
        VC.dataDic = @{@"OrderId" : _order_id, @"OrderNo" : _ORDER_NO};
        [self.navigationController pushViewController:VC animated:YES];
        
    } else {
        NSInteger totalTime = 0;
        NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
        NSString *cust_id = [RMMFileManager retrunObjWith:[RMMFileManager shareHandle].userDic[@"CUST_ID"]];
        parDic[@"org_no"] = Org_no;
        parDic[@"cust_id"] = cust_id;
        parDic[@"payment"] = [NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
        [RMMFileManager shareHandle].totalPrcie = [NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie];
        
        NSMutableArray *array = [NSMutableArray array];
        for (RMMShopingModel *model in _goodsArray) {
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            dic[@"my_card_id"] = model.MY_CARD_ID;
            dic[@"ser_id"] = model.SERVICE_ID;
            dic[@"ser_name"] = model.SERVICE_NAME;
            dic[@"prod_cnt"] = [NSString stringWithFormat:@"%@",model.COUNT];
            dic[@"price"] = model.PRICE;
            [array addObject:dic];
            NSInteger time = [model.TIME_LEN integerValue] * [model.COUNT integerValue];
            totalTime += time;
        }
        for (RMMShopingModel *model in _arrayT) {
            if ([model.isSelect isEqualToString:@"1"]) {
                NSMutableDictionary *dic = [NSMutableDictionary dictionary];
                dic[@"my_card_id"] = model.MY_CARD_ID;
                dic[@"ser_id"] = model.SERVICE_ID;
                dic[@"ser_name"] = model.SERVICE_NAME;
                dic[@"prod_cnt"] = [NSString stringWithFormat:@"%@",model.COUNT];
                dic[@"price"] = model.PRICE;
                [array addObject:dic];
                NSInteger time = [model.TIME_LEN integerValue] * [model.COUNT integerValue];
                totalTime += time;
            }
        }
        parDic[@"servers"] = array;
        parDic[@"order_source"] = @"1";
        parDic[@"region_id"] = [RMMFileManager shareHandle].region_id;
        [RMMFileManager shareHandle].totalTimeLength = [NSString stringWithFormat:@"%ld",totalTime];
        NSString *url = CreaterServerOrderUrl;
        [OSRequestManager requestWithUrlString:url parDic:parDic method:POST finish:^(NSDictionary *dataDic) {
            NSString *status = [NSString stringWithFormat:@"%@",dataDic[@"status"]];
            if ([status isEqualToString:@"1"]) {
                NSMutableArray *gArray = [NSMutableArray arrayWithArray:_goodsArray];
                for (RMMShopingModel *model in _arrayT) {
                    if ([model.isSelect isEqualToString:@"1"]) {
                        [gArray addObject:model];
                    }
                }
                NS_POST(@"ORDERUPDATA", nil, nil);
                [_youHuiDic setValue:_yanZhiText forKey:@"颜值"];
                [_youHuiDic setValue:_is_face forKey:@"是否使用颜值"];
                [_youHuiDic setValue:[NSString stringWithFormat:@"%d",_isUsedYouHuiCard] forKey:@"是否使用优惠券"];
                [_youHuiDic setObject:[NSString stringWithFormat:@"%.2f",[self getToatalPriceWithArray:_arrayT] + _totalPrcie] forKey:@"总价钱"];
                [self processData];
                if ([[RMMFileManager shareHandle].fromSkillType isEqualToString:@"1"]) {
                    RMMChosseDateViewController *VC = [[RMMChosseDateViewController alloc] init];
                    VC.dataArray = gArray;
                    VC.youHuiDic = _youHuiDic;
                    VC.order_id_dic = dataDic[@"data"];
                    VC.isHome = _isHome;
                    [self.navigationController pushViewController:VC animated:YES];
                } else {
                    RMMUpOrderViewController *VC = [[RMMUpOrderViewController alloc] init];
                    VC.dataArray = gArray;
                    VC.youHuiDic = _youHuiDic;
                    VC.isHome = _isHome;
                    VC.dataDic = dataDic[@"data"];
                    [self.navigationController pushViewController:VC animated:YES];
                }
  
            } else {
                [RMMFileManager MBProgressWith:dataDic[@"message"] onView:self.view];
            }
        } error:^(NSError *errors) {
            
        } view:self.view];
    }
}
- (void)processData{
    NSString *is_face = [_youHuiDic objectForKey:@"是否使用颜值"];
    CGFloat yanzhiMoney = 0.00;
    CGFloat totalPrice = [self getToatalPriceWithArray:_arrayT] + _totalPrcie;
    CGFloat shengYuPrice = 0.00;
    if ([is_face isEqualToString:@"1"]) {
        yanzhiMoney = [[_youHuiDic objectForKey:@"颜值"] floatValue];
        NSString *is_youHui = [_youHuiDic objectForKey:@"是否使用优惠券"];
        if ([is_youHui isEqualToString:@"1"]) {
            NSDictionary *dic = [_youHuiDic objectForKey:@"优惠券信息"];
            NSString *type = [NSString stringWithFormat:@"%@",dic[@"CARD_TYPE"]];
            if ([type isEqualToString:@"4"]) {
                // 折扣
                NSString *zekou = dic[@"DISCOUNT_RATE"];
                shengYuPrice = totalPrice * [zekou floatValue] - [_yanZhiText floatValue];
            } else if ([type isEqualToString:@"6"]) {
                // 带金券
                NSString *daiMoney = dic[@"PAR_AMT"];
                if (totalPrice - [daiMoney floatValue] < 0) {
                    shengYuPrice = 0;
                    _yanZhiText = @"0";
                } else {
                    shengYuPrice = totalPrice - [daiMoney floatValue] - [_yanZhiText floatValue];
                }
            }
        } else {
            shengYuPrice = totalPrice - [_yanZhiText floatValue];
        }
        
    } else {
        NSString *is_youHui = [_youHuiDic objectForKey:@"是否使用优惠券"];
        if ([is_youHui isEqualToString:@"1"]) {
            NSDictionary *dic = [_youHuiDic objectForKey:@"优惠券信息"];
            NSString *type = [NSString stringWithFormat:@"%@",dic[@"CARD_TYPE"]];
            if ([type isEqualToString:@"4"]) {
                // 折扣
                NSString *zekou = dic[@"DISCOUNT_RATE"];
                shengYuPrice = totalPrice * [zekou floatValue] - [_yanZhiText floatValue];
            } else if ([type isEqualToString:@"6"]) {
                // 带金券
                NSString *daiMoney = dic[@"PAR_AMT"];
                if (totalPrice - [daiMoney floatValue] < 0) {
                    shengYuPrice = 0;
                    _yanZhiText = @"0";
                } else {
                    shengYuPrice = totalPrice - [daiMoney floatValue] - [_yanZhiText floatValue];
                }
            }
        } else {
            shengYuPrice = totalPrice - [_yanZhiText floatValue];
        }
    }
    if (shengYuPrice <= 0) {
        yanzhiMoney = shengYuPrice + [_yanZhiText floatValue];
        [_youHuiDic setObject:@"0" forKey:@"总价钱"];
    }
    [_youHuiDic setValue:[NSString stringWithFormat:@"%.2f",yanzhiMoney] forKey:@"颜值"];
}
- (CGFloat)getToatalPriceWithArray:(NSMutableArray *)array{
    CGFloat totalPrcie = 0.00;
    for (RMMShopingModel *model in array) {
        if ([model.isSelect isEqualToString:@"1"]) {
            if ([model.MY_CARD_ID isEqualToString:@"0"]) {
                CGFloat prcie = [model.PRICE floatValue];
                NSInteger count = [model.COUNT integerValue];
                totalPrcie += prcie * count;
            }
        }
    }
    return totalPrcie;
}
// 显示更多
- (void)moreButClick{
    [RMMFileManager MBProgressWith:@"没有更多了!" onView:self.view];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
